Showing posts with label knows. Show all posts
Showing posts with label knows. Show all posts

Tuesday, February 14, 2012

column as variable

I have a problem that I'm sure is very simple to answer for anyone that knows a bit of T-SQL. In a stored procedure, I simply want to concatenate a string variable containing a column name into a Select statement.

For example:
I want to execute the following statement but using a variable for the column name:

Select * from tblmet1araw where JulianDay = 1

JulianDay is an integer
This is how I have my code set up:

declare @.xxx as varchar(20)
set @.theday = 'JulianDay'

select * from tblmet1araw where @.theday = 1

I get the following error:
Server: Msg 245, Level 16, State 1, Line 4
Syntax error converting the varchar value 'JulianDay' to a column of data type int.declare @.col varchar(10)
set @.col='id'
exec('select * from sysobjects where '+@.col+'=1')|||Thanks. That works.

Friday, February 10, 2012

Collation Problem Using Openquery to insert record to Oracle

Hi,
I am trying to insert a record into an Oracle 9.2 instance from Microsoft's
SQL Server 2000 using openquery, it is really slow, someone knows if it has
to do with differences between SQL Collation setting and Oracle's NLS_SORT,
my current setings are:
SQL: SQL_Latin1_General_CP1_CI_AS
Oracle NLS_SORT: Binary
I configured the Linked server with the Use Remote Collation option and left
the collation name blank.
Thanks a lot!!
IgnacioHi
You don't say how the oracle server is linked and which drivers/versions you
are using.
Are you getting any error messages?
What are you doing with returned data?
John
"i-DLT" wrote:

> Hi,
> I am trying to insert a record into an Oracle 9.2 instance from Microsoft'
s
> SQL Server 2000 using openquery, it is really slow, someone knows if it ha
s
> to do with differences between SQL Collation setting and Oracle's NLS_SORT
,
> my current setings are:
> SQL: SQL_Latin1_General_CP1_CI_AS
> Oracle NLS_SORT: Binary
> I configured the Linked server with the Use Remote Collation option and le
ft
> the collation name blank.
> Thanks a lot!!
> Ignacio