SQL转换没有列名

时间:2017-08-07 14:24:25

标签: sql-server reporting-services

我有以下SQL语句

#include<stdio.h>
#include<string.h>

char *findStringReverse(char *);

int main(){
   char str[50];

   printf("Enter a String\n");
   scanf("%s", str);
   if( strlen(str) > 10 )
   {
       printf("Invalid String.");
       return 0;
   }

   printf("Reverse of the String: %s\n",findStringReverse(str));

}

char *findStringReverse(char *str){
   int i,len;
   char rev[10];
   len = strlen(str);
   for(i=0;i<=len;i++)
      rev[i] = str[len-i-1];
   printf("%s\n",rev);         // Here it prints the reverse of the string.
   return rev;                 // But unable to return.
 }    

以[{1}}和SELECT DISTINCT CAST(CONVERT(CHAR(16), AuditDate,113) AS datetime), DisplayName FROM myTable WHERE DisplayName IS NOT NULL ORDER BY DisplayName asc 返回的两列,后者是个问题。我在SSRS报告中使用它,我需要将AuditDate值传递给它。结果现在为Display name我的报告缺少信息。

我该如何解决这个问题?

3 个答案:

答案 0 :(得分:4)

为列添加如下别名:

arrayVar.indexOf(message.content)

SELECT DISTINCT CAST(CONVERT(CHAR(16), AuditDate,113) AS datetime) AS 'Audit Date' 

取决于您的首选语法

答案 1 :(得分:2)

只需将alias添加到结果列

即可
CAST(CONVERT(CHAR(16), AuditDate,113) AS datetime) AS [AuditDate]

答案 2 :(得分:1)

SELECT DISTINCT 
    CAST(CONVERT(CHAR(16), AuditDate,113) AS datetime) AS AuditDate, 
    DisplayName
FROM     
    myTable
WHERE 
    DisplayName IS NOT NULL
ORDER BY 
    DisplayName ASC