What Is Sysname?
Oct 23, 2006USE <database, sysname, AdventureWorks>
What is "sysname" object? I frequently see it among parameters for stored procedures.
Thanks.
USE <database, sysname, AdventureWorks>
What is "sysname" object? I frequently see it among parameters for stored procedures.
Thanks.
Hi ALL,
What does "sysname" type indicates.
USE <database, sysname, AdventureWorks>
GO
IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_table>', 'U') IS NOT NULL
DROP TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table>
GOCREATE TABLE <schema_name, sysname, dbo>.<table_name, sysname, sample_table>
(<columns_in_primary_key, , c1> <column1_datatype, , int> <column1_nullability,, NOT NULL>,
<column2_name, sysname, c2> <column2_datatype, , char(10)> <column2_nullability,, NULL>, <column3_name, sysname, c3> <column3_datatype, , datetime> <column3_nullability,, NULL>,
CONSTRAINT <contraint_name, sysname, PK_sample_table> PRIMARY KEY (<columns_in_primary_key, , c1>)
)
GO
Hi.
I`m new to MS Sql and have been studying some tutorials and stuff.
What I can`t get a hold of is this sysname-thing. I see it is referenced to when i.e you create a new table...
Can anyone help me?
Freddy....
Hi,
In SQL Server 2005 Express BOL,
it says in 'Arguments' description part like this.
user_name
Specifies the name by which the user is identified inside this database. user_name is a sysname.
It can be up to 128 characters long.
What 'user_name is a sysname' imply?
Okely dokely, here it is.I have a database that has a differing collation to that of the tempdb. And obviously because of this I've run into problems when referencing table variables and temp tables. BUT! Given the following example, what am I doing wrong, or is there no solution to this. <Start Example>/*================================================= ================================================== ==========================fnPM_ForeignKey ================================================== ================================================== =========================*/IF exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fnPM_ForeignKey]')) BEGINDROP FUNCTION [dbo].[fnPM_ForeignKey]ENDGOCREATE FUNCTION fnPM_ForeignKey (@ChildTable as sysname, @ChildColumn as sysname)RETURNS @ForeignKey TABLE (FKName sysname,ParentTable sysname,ParentColumn sysname,DescriptionColumn sysname COLLATE SQL_Latin1_General_CP1_CI_AS)ASBEGININSERT INTO @ForeignKey (FKName, ParentTable, ParentColumn)SELECT FK.Name, Parent.Name, ParentCol.NameFROM sysforeignkeysINNER JOIN sysobjects FK on sysforeignkeys.constid = FK.IDINNER JOIN sysobjects Parent on sysforeignkeys.rkeyid = Parent.idINNER JOIN syscolumns ParentCol on ParentCol.id = Parent.id and sysforeignkeys.rkey = ParentCol.colidINNER JOIN sysobjects Child on sysforeignkeys.fkeyid = Child.idINNER JOIN syscolumns ChildCol on ChildCol.id = Child.id and sysforeignkeys.fkey = ChildCol.colid WHERE Child.Name = @ChildTable and ChildCol.Name = @ChildColumn--> UPDATE @ForeignKey Set DescriptionColumn = syscolumns.Name COLLATE SQL_Latin1_General_CP1_CI_ASFROM @ForeignKey ForeignKeyINNER JOIN sysobjects on ForeignKey.ParentTable = sysobjects.NameINNER JOIN syscolumns on syscolumns.id = sysobjects.idWHERE syscolumns.Name like '%Name%'UPDATE @ForeignKey Set DescriptionColumn = syscolumns.NameFROM @ForeignKey ForeignKeyINNER JOIN sysobjects on ForeignKey.ParentTable = sysobjects.NameINNER JOIN syscolumns on syscolumns.id = sysobjects.idWHERE ForeignKey.DescriptionColumn is null and syscolumns.Name like '%Description%'RETURN ENDGO< end example >So here I'm defining my function which basically returns the parent table details of a given foreign key relationship. But when trying to run the above script I get this,Server: Msg 446, Level 16, State 9, Procedure fnPM_ForeignKey, Line 22Cannot resolve collation conflict for equal to operation.First up I find this weird because isn't sysname equvalent to nvarchar(128)? And aren't nvarchar fields independant of collation? But it gets better,I thought, ok maybe I'm wrong about sysname needing collation, so I figured I'll check the collation of the syscolumns.name column,Heres the queryselect sysobjects.Name, syscolumns.name, syscolumns.collationfrom sysobjects inner join syscolumns on sysobjects.id = syscolumns.idwhere sysobjects.name ='syscolumns' and syscolumns.name = 'name'This is what it returns,syscolumnsnameSQL_Latin1_General_CP1_CI_ASSo, let me get this straight, I've explicitly stated that the table variable column is collation SQL_Latin1_General_CP1_CI_ASand the column I'm comparing it to also has a collation of SQL_Latin1_General_CP1_CI_AS, and it doesn't work. . . .I smell Microsoft, or is there something equally as hideous going on here.RegardsAdam.
View 1 Replies View Related